.class public Les/a7;
.super Ljava/lang/Object;
.source "AnimatedMultiThreadGifEncoder.java"


# instance fields
.field private a:Z

.field private b:Ljava/io/OutputStream;

.field private c:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Les/b7;",
            ">;"
        }
    .end annotation
.end field

.field private d:Les/vc;

.field private e:Ljava/lang/Thread;

.field private f:I

.field private g:I

.field private h:Lcom/esfile/screen/recorder/media/util/y;

.field private i:Ljava/util/Set;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Set<",
            "Les/c7;",
            ">;"
        }
    .end annotation
.end field

.field private j:Ljava/util/concurrent/atomic/AtomicBoolean;


# direct methods
.method public constructor <init>()V
    .locals 2

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Les/a7;->a:Z

    .line 3
    new-instance v1, Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-direct {v1, v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>(Z)V

    iput-object v1, p0, Les/a7;->j:Ljava/util/concurrent/atomic/AtomicBoolean;

    return-void
.end method

.method static synthetic a(Les/a7;)I
    .locals 0

    .line 1
    iget p0, p0, Les/a7;->g:I

    return p0
.end method

.method private a(III)V
    .locals 0
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 29
    invoke-direct {p0, p1}, Les/a7;->c(I)V

    .line 30
    invoke-direct {p0, p2}, Les/a7;->c(I)V

    .line 31
    iget-object p1, p0, Les/a7;->b:Ljava/io/OutputStream;

    or-int/lit8 p2, p3, 0x70

    invoke-virtual {p1, p2}, Ljava/io/OutputStream;->write(I)V

    .line 32
    iget-object p1, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/4 p2, 0x0

    invoke-virtual {p1, p2}, Ljava/io/OutputStream;->write(I)V

    .line 33
    iget-object p1, p0, Les/a7;->b:Ljava/io/OutputStream;

    invoke-virtual {p1, p2}, Ljava/io/OutputStream;->write(I)V

    return-void
.end method

.method static synthetic b(Les/a7;)Lcom/esfile/screen/recorder/media/util/y;
    .locals 0

    .line 1
    iget-object p0, p0, Les/a7;->h:Lcom/esfile/screen/recorder/media/util/y;

    return-object p0
.end method

.method private b(Ljava/lang/String;)V
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    const/4 v0, 0x0

    .line 15
    :goto_0
    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v1

    if-ge v0, v1, :cond_0

    .line 16
    iget-object v1, p0, Les/a7;->b:Ljava/io/OutputStream;

    invoke-virtual {p1, v0}, Ljava/lang/String;->charAt(I)C

    move-result v2

    int-to-byte v2, v2

    invoke-virtual {v1, v2}, Ljava/io/OutputStream;->write(I)V

    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    :cond_0
    return-void
.end method

.method static synthetic c(Les/a7;)Ljava/util/Set;
    .locals 0

    .line 1
    iget-object p0, p0, Les/a7;->i:Ljava/util/Set;

    return-object p0
.end method

.method private c()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 2
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/16 v1, 0x21

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 3
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/16 v1, 0xff

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 4
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/16 v1, 0xb

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    const-string v0, "NETSCAPE2.0"

    .line 5
    invoke-direct {p0, v0}, Les/a7;->b(Ljava/lang/String;)V

    .line 6
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/4 v1, 0x3

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 7
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 8
    iget v0, p0, Les/a7;->f:I

    invoke-direct {p0, v0}, Les/a7;->c(I)V

    .line 9
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    return-void
.end method

.method private c(I)V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 10
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    and-int/lit16 v1, p1, 0xff

    invoke-virtual {v0, v1}, Ljava/io/OutputStream;->write(I)V

    .line 11
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    shr-int/lit8 p1, p1, 0x8

    and-int/lit16 p1, p1, 0xff

    invoke-virtual {v0, p1}, Ljava/io/OutputStream;->write(I)V

    return-void
.end method

.method static synthetic d(Les/a7;)Ljava/util/concurrent/atomic/AtomicBoolean;
    .locals 0

    .line 1
    iget-object p0, p0, Les/a7;->j:Ljava/util/concurrent/atomic/AtomicBoolean;

    return-object p0
.end method

.method static synthetic e(Les/a7;)Ljava/util/List;
    .locals 0

    .line 1
    iget-object p0, p0, Les/a7;->c:Ljava/util/List;

    return-object p0
.end method

.method static synthetic f(Les/a7;)Ljava/io/OutputStream;
    .locals 0

    .line 1
    iget-object p0, p0, Les/a7;->b:Ljava/io/OutputStream;

    return-object p0
.end method


# virtual methods
.method public a()V
    .locals 4

    .line 34
    iget-object v0, p0, Les/a7;->d:Les/vc;

    invoke-virtual {v0}, Les/vc;->shutdown()V

    .line 35
    iget-object v0, p0, Les/a7;->j:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 36
    iget-object v0, p0, Les/a7;->i:Ljava/util/Set;

    invoke-interface {v0}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_0

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Les/c7;

    .line 37
    :try_start_0
    invoke-virtual {v1}, Les/c7;->a()V
    :try_end_0
    .catch Lcom/esfile/screen/recorder/gif/encoder/utils/CancelledException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v1

    const-string v2, "AnimatedMultiThreadGifEncoder"

    const-string v3, "cant exception"

    .line 38
    invoke-static {v2, v3, v1}, Lcom/esfile/screen/recorder/utils/n;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_0

    :cond_0
    return-void
.end method

.method public a(I)V
    .locals 0

    .line 2
    iput p1, p0, Les/a7;->g:I

    return-void
.end method

.method public a(IILjava/lang/String;)Z
    .locals 1

    .line 3
    invoke-virtual {p0, p3}, Les/a7;->a(Ljava/lang/String;)Z

    move-result p3

    const/4 v0, 0x0

    if-eqz p3, :cond_0

    .line 4
    :try_start_0
    new-instance p3, Ljava/util/HashSet;

    invoke-direct {p3}, Ljava/util/HashSet;-><init>()V

    invoke-static {p3}, Ljava/util/Collections;->synchronizedSet(Ljava/util/Set;)Ljava/util/Set;

    move-result-object p3

    iput-object p3, p0, Les/a7;->i:Ljava/util/Set;

    .line 5
    new-instance p3, Lcom/esfile/screen/recorder/media/util/y;

    invoke-direct {p3, p1, p2}, Lcom/esfile/screen/recorder/media/util/y;-><init>(II)V

    iput-object p3, p0, Les/a7;->h:Lcom/esfile/screen/recorder/media/util/y;

    .line 6
    invoke-virtual {p3}, Lcom/esfile/screen/recorder/media/util/y;->b()I

    move-result p1

    iget-object p2, p0, Les/a7;->h:Lcom/esfile/screen/recorder/media/util/y;

    invoke-virtual {p2}, Lcom/esfile/screen/recorder/media/util/y;->a()I

    move-result p2

    invoke-direct {p0, p1, p2, v0}, Les/a7;->a(III)V

    .line 7
    invoke-direct {p0}, Les/a7;->c()V

    const/4 p1, 0x1

    .line 8
    iput-boolean p1, p0, Les/a7;->a:Z
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    return p1

    :catch_0
    :cond_0
    return v0
.end method

.method public a(Landroid/graphics/Bitmap;J)Z
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/esfile/screen/recorder/gif/encoder/utils/CancelledException;
        }
    .end annotation

    if-eqz p1, :cond_1

    .line 9
    iget-boolean v0, p0, Les/a7;->a:Z

    if-nez v0, :cond_0

    goto :goto_1

    .line 10
    :cond_0
    new-instance v0, Les/b7;

    invoke-direct {v0}, Les/b7;-><init>()V

    .line 11
    iput-wide p2, v0, Les/b7;->b:J

    .line 12
    iput-object p1, v0, Les/b7;->a:Landroid/graphics/Bitmap;

    .line 13
    iget-object p1, p0, Les/a7;->c:Ljava/util/List;

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 14
    new-instance p1, Ljava/util/concurrent/CountDownLatch;

    const/4 p2, 0x1

    invoke-direct {p1, p2}, Ljava/util/concurrent/CountDownLatch;-><init>(I)V

    .line 15
    new-instance p3, Ljava/lang/StringBuilder;

    invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "content add,task in queue "

    invoke-virtual {p3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget-object v1, p0, Les/a7;->c:Ljava/util/List;

    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v1

    invoke-virtual {p3, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p3

    const-string v1, "AnimatedMultiThreadGifEncoder"

    invoke-static {v1, p3}, Lcom/esfile/screen/recorder/utils/n;->d(Ljava/lang/String;Ljava/lang/String;)V

    .line 16
    iget-object p3, p0, Les/a7;->d:Les/vc;

    new-instance v2, Les/a7$a;

    invoke-direct {v2, p0, p1, v0}, Les/a7$a;-><init>(Les/a7;Ljava/util/concurrent/CountDownLatch;Les/b7;)V

    invoke-virtual {p3, v2}, Les/vc;->execute(Ljava/lang/Runnable;)V

    .line 17
    :try_start_0
    invoke-virtual {p1}, Ljava/util/concurrent/CountDownLatch;->await()V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception p1

    const-string p3, "wait occurs a interrupt."

    .line 18
    invoke-static {v1, p3, p1}, Lcom/esfile/screen/recorder/utils/n;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 19
    invoke-static {p3}, Lcom/esfile/screen/recorder/utils/n;->a(Ljava/lang/String;)V

    :goto_0
    return p2

    :cond_1
    :goto_1
    const/4 p1, 0x0

    return p1
.end method

.method public a(Ljava/io/OutputStream;)Z
    .locals 6

    const/4 v0, 0x0

    if-nez p1, :cond_0

    return v0

    .line 20
    :cond_0
    iput-object p1, p0, Les/a7;->b:Ljava/io/OutputStream;

    :try_start_0
    const-string p1, "GIF89a"

    .line 21
    invoke-direct {p0, p1}, Les/a7;->b(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 22
    new-instance p1, Ljava/util/LinkedList;

    invoke-direct {p1}, Ljava/util/LinkedList;-><init>()V

    invoke-static {p1}, Ljava/util/Collections;->synchronizedList(Ljava/util/List;)Ljava/util/List;

    move-result-object p1

    iput-object p1, p0, Les/a7;->c:Ljava/util/List;

    .line 23
    sget p1, Les/xc;->a:I

    mul-int/lit8 v2, p1, 0x3

    mul-int/lit8 v3, p1, 0x3

    .line 24
    new-instance p1, Les/vc;

    new-instance v1, Ljava/util/concurrent/LinkedBlockingQueue;

    invoke-direct {v1}, Ljava/util/concurrent/LinkedBlockingQueue;-><init>()V

    const/4 v4, 0x0

    const/16 v5, 0xa

    move-object v0, p1

    invoke-direct/range {v0 .. v5}, Les/vc;-><init>(Ljava/util/Queue;IIII)V

    iput-object p1, p0, Les/a7;->d:Les/vc;

    .line 25
    new-instance p1, Ljava/lang/Thread;

    new-instance v0, Les/a7$c;

    invoke-direct {v0, p0}, Les/a7$c;-><init>(Les/a7;)V

    const-string v1, "FlushThread"

    invoke-direct {p1, v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    iput-object p1, p0, Les/a7;->e:Ljava/lang/Thread;

    .line 26
    invoke-virtual {p1}, Ljava/lang/Thread;->start()V

    const/4 p1, 0x1

    return p1

    :catch_0
    return v0
.end method

.method public a(Ljava/lang/String;)Z
    .locals 2

    .line 27
    :try_start_0
    new-instance v0, Ljava/io/BufferedOutputStream;

    new-instance v1, Ljava/io/FileOutputStream;

    invoke-direct {v1, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V

    invoke-direct {v0, v1}, Ljava/io/BufferedOutputStream;-><init>(Ljava/io/OutputStream;)V

    iput-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    .line 28
    invoke-virtual {p0, v0}, Les/a7;->a(Ljava/io/OutputStream;)Z

    move-result p1
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    return p1

    :catch_0
    const/4 p1, 0x0

    return p1
.end method

.method public b(I)V
    .locals 0

    .line 2
    iput p1, p0, Les/a7;->f:I

    return-void
.end method

.method public b()Z
    .locals 4

    .line 3
    iget-boolean v0, p0, Les/a7;->a:Z

    const/4 v1, 0x0

    if-nez v0, :cond_0

    return v1

    .line 4
    :cond_0
    iget-object v0, p0, Les/a7;->j:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v0

    if-eqz v0, :cond_1

    return v1

    .line 5
    :cond_1
    new-instance v0, Les/b7;

    invoke-direct {v0}, Les/b7;-><init>()V

    const-wide/16 v2, -0x1

    .line 6
    iput-wide v2, v0, Les/b7;->b:J

    .line 7
    iget-object v2, p0, Les/a7;->c:Ljava/util/List;

    invoke-interface {v2, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 8
    iget-object v2, p0, Les/a7;->d:Les/vc;

    new-instance v3, Les/a7$b;

    invoke-direct {v3, p0, v0}, Les/a7$b;-><init>(Les/a7;Les/b7;)V

    invoke-virtual {v2, v3}, Les/vc;->execute(Ljava/lang/Runnable;)V

    .line 9
    :try_start_0
    iget-object v0, p0, Les/a7;->e:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->join()V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    const-string v2, "cant interrupted here"

    .line 10
    invoke-static {v2, v0}, Lcom/esfile/screen/recorder/utils/n;->a(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 11
    :goto_0
    :try_start_1
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    const/16 v2, 0x3b

    invoke-virtual {v0, v2}, Ljava/io/OutputStream;->write(I)V

    .line 12
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V

    .line 13
    iget-object v0, p0, Les/a7;->b:Ljava/io/OutputStream;

    invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1

    .line 14
    iput-boolean v1, p0, Les/a7;->a:Z

    const/4 v0, 0x1

    return v0

    :catch_1
    return v1
.end method
